package cn.com.member.controller.match;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.com.api.entity.ApiU_match_works;
import cn.com.api.service.ApiU_match_voteService;
import cn.com.api.service.ApiU_match_worksService;
import cn.com.util.Utils;

@Controller
@RequestMapping(Utils.SYS_VIEWS+"/")
public class U_match_worksController  {

	private static Logger logger = Logger.getLogger(U_match_worksController.class);
	
	@Autowired
	private ApiU_match_worksService apiU_match_worksService;
	
	@Autowired
	private ApiU_match_voteService apiU_match_voteService;
	/**
	 * 获取已报名人数
	 * @return
	 */
	@RequestMapping(value = "u_match-works-list")
	public ModelAndView u_match_works_list(HttpServletRequest request, HttpServletResponse response) throws Exception{
		ModelAndView mv = new ModelAndView("/match/u_match_works_list");
		try {
			
			if(request.getParameter("id") != null){
				String id = request.getParameter("id");
			
				List<ApiU_match_works> list_match_works = apiU_match_worksService.findU_match_worksByMatchId(Integer.valueOf(id));				
				String enroll_num = request.getParameter("enroll_num");
				int vote_num = apiU_match_voteService.findU_vote_numByMatchId(Integer.valueOf(id));
				if(enroll_num == null || enroll_num.equals("")){
					enroll_num = "0";
				}
				mv.addObject("list_match_works",list_match_works);
				mv.addObject("enroll_num",enroll_num);
				mv.addObject("vote_num",vote_num);
			}
		} catch (Exception e) {
			logger.error("===========[U_matchController[u_match_works_info_pre[获取报名人员信息列表失败]]]========", e);
		}
		return mv;
	}
	
	
}



